<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Vue</title>
    <link rel="stylesheet" href="/css/common.css">
    <style>
        .info > div {
            border: 1px solid lightgray;
            padding: 4px;
            border-radius: 2px;
            margin-top: 16px;
        }
    </style>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
</head><body>
<div id="app">
    <h1>{{ appName }}</h1>
    <user-info class="info">
        <div>组件默认插槽</div>
        <div slot="action"><button>按钮</button></div>
    </user-info>
</div>
<script type="text/javascript">
    Vue.component('UserInfo', {
        data: function () {
            return { account: 'admin' }
        },
        template: `<div class="info">
                      <div>User info: {{account}}</div>
                      <slot></slot>
                      <slot name="action"></slot>
                   </div>`
    })
    new Vue({ el: '#app', data: { appName: 'My App' } })
</script></body></html>
